﻿using System;
namespace Producers.Liiklusregister.Xtee.Riik.Ee.Producer.Liiklusregister {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paring22_soidukiandmed", Namespace="http://producers.liiklusregister.xtee.riik.ee/producer/liiklusregister", Target=typeof(Paring22Soidukiandmed))]
    public class Paring22SoidukiandmedSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParing22Soidukiandmed clazz;
        
        public Paring22SoidukiandmedSerializer(IParing22Soidukiandmed clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("regmrk");
            if (clazz.Regmrk!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regmrk))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Regmrk");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mark");
            if (clazz.Mark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mark))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mark");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mudel");
            if (clazz.Mudel!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mudel))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mudel");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("varvus");
            if (clazz.Varvus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Varvus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Varvus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("regtulek");
            if (clazz.Regtulek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regtulek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Regtulek");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ehitaasta");
            if (clazz.Ehitaasta!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Ehitaasta))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Ehitaasta");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mootv");
            if (clazz.Mootv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Mootv))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Mootv");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("regtkuup");
            if (clazz.Regtkuup!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Regtkuup))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Regtkuup");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oma_kood");
            if (clazz.OmaKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oma_nimi");
            if (clazz.OmaNimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaNimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaNimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oma_eesnimi");
            if (clazz.OmaEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oma_aadress");
            if (clazz.OmaAadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaAadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaAadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("oma_asukoht");
            if (clazz.OmaAsukoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmaAsukoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : OmaAsukoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vk_kood");
            if (clazz.VkKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VkKood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VkKood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vk_nimi");
            if (clazz.VkNimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VkNimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VkNimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vk_eesnimi");
            if (clazz.VkEesnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VkEesnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VkEesnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vk_aadress");
            if (clazz.VkAadress!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VkAadress))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VkAadress");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("vk_asukoht");
            if (clazz.VkAsukoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VkAsukoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VkAsukoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("piirangud");
            if (clazz.Piirangud!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Piirangud))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "regmrk")) {
                goto regmrk;
            }
            else {
                if ((Reader.LocalName == "mark")) {
                    goto mark;
                }
                else {
                    if ((Reader.LocalName == "mudel")) {
                        goto mudel;
                    }
                    else {
                        if ((Reader.LocalName == "varvus")) {
                            goto varvus;
                        }
                        else {
                            if ((Reader.LocalName == "regtulek")) {
                                goto regtulek;
                            }
                            else {
                                if ((Reader.LocalName == "ehitaasta")) {
                                    goto ehitaasta;
                                }
                                else {
                                    if ((Reader.LocalName == "mootv")) {
                                        goto mootv;
                                    }
                                    else {
                                        if ((Reader.LocalName == "regtkuup")) {
                                            goto regtkuup;
                                        }
                                        else {
                                            if ((Reader.LocalName == "oma_kood")) {
                                                goto oma_kood;
                                            }
                                            else {
                                                if ((Reader.LocalName == "oma_nimi")) {
                                                    goto oma_nimi;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "oma_eesnimi")) {
                                                        goto oma_eesnimi;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "oma_aadress")) {
                                                            goto oma_aadress;
                                                        }
                                                        else {
                                                            if ((Reader.LocalName == "oma_asukoht")) {
                                                                goto oma_asukoht;
                                                            }
                                                            else {
                                                                if ((Reader.LocalName == "vk_kood")) {
                                                                    goto vk_kood;
                                                                }
                                                                else {
                                                                    if ((Reader.LocalName == "vk_nimi")) {
                                                                        goto vk_nimi;
                                                                    }
                                                                    else {
                                                                        if ((Reader.LocalName == "vk_eesnimi")) {
                                                                            goto vk_eesnimi;
                                                                        }
                                                                        else {
                                                                            if ((Reader.LocalName == "vk_aadress")) {
                                                                                goto vk_aadress;
                                                                            }
                                                                            else {
                                                                                if ((Reader.LocalName == "vk_asukoht")) {
                                                                                    goto vk_asukoht;
                                                                                }
                                                                                else {
                                                                                    if ((Reader.LocalName == "piirangud")) {
                                                                                        goto piirangud;
                                                                                    }
                                                                                    else {
                                                                                        return;
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        regmrk:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>regmrk");
            }
            clazz.Regmrk = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regmrk")).Value;
            goto START;
        mark:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>mark");
            }
            clazz.Mark = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mark")).Value;
            goto START;
        mudel:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>mudel");
            }
            clazz.Mudel = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mudel")).Value;
            goto START;
        varvus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>varvus");
            }
            clazz.Varvus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("varvus")).Value;
            goto START;
        regtulek:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>regtulek");
            }
            clazz.Regtulek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regtulek")).Value;
            goto START;
        ehitaasta:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>ehitaasta");
            }
            clazz.Ehitaasta = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ehitaasta")).Value;
            goto START;
        mootv:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>mootv");
            }
            clazz.Mootv = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("mootv")).Value;
            goto START;
        regtkuup:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>regtkuup");
            }
            clazz.Regtkuup = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("regtkuup")).Value;
            goto START;
        oma_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>oma_kood");
            }
            clazz.OmaKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_kood")).Value;
            goto START;
        oma_nimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>oma_nimi");
            }
            clazz.OmaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_nimi")).Value;
            goto START;
        oma_eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>oma_eesnimi");
            }
            clazz.OmaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_eesnimi")).Value;
            goto START;
        oma_aadress:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>oma_aadress");
            }
            clazz.OmaAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_aadress")).Value;
            goto START;
        oma_asukoht:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>oma_asukoht");
            }
            clazz.OmaAsukoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("oma_asukoht")).Value;
            goto START;
        vk_kood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>vk_kood");
            }
            clazz.VkKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vk_kood")).Value;
            goto START;
        vk_nimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>vk_nimi");
            }
            clazz.VkNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vk_nimi")).Value;
            goto START;
        vk_eesnimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>vk_eesnimi");
            }
            clazz.VkEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vk_eesnimi")).Value;
            goto START;
        vk_aadress:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>vk_aadress");
            }
            clazz.VkAadress = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vk_aadress")).Value;
            goto START;
        vk_asukoht:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>paring22_soidukiandmed>vk_asukoht");
            }
            clazz.VkAsukoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("vk_asukoht")).Value;
            goto START;
        piirangud:
            if ((Reader.IsElementNil() == false)) {
                clazz.Piirangud = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("piirangud")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
    }
}
